package com.kabuda.controller;

import com.kabuda.domain.User;
import com.kabuda.service.UserService;
import com.kabuda.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author kabuda
 * @create 2023-10-17 22:10
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @PostMapping("/login")
    public R login(@RequestBody User user){
        Map<String,Object> map=userService.login(user);
        return R.success(map);
    }
    @GetMapping("/logout")
    public R logout(@RequestParam("token") String token){
       userService.logout(token);
        return R.success();
    }
    @GetMapping("/curUserInfo")
    public R curUser(@RequestParam("token") String token){
        User user=userService.curUserInfo(token);
        return R.success("user",user);
    }
}
